#ifndef _PDH_H
#define _PDH_H

#include <pdh.h>
#include <utillib/util/Synchronized.h>

#pragma warning (disable: 4786)

#include <set>
#include <functional>


namespace cpp
{
	namespace lang
	{
#define MAX_COUNTER_NAME	100
		class PDH
		{
		public:
			typedef HCOUNTER* PDHCounter;
			enum
			{
				PROCESS_HANDLE = 0,
				PROCESS_PROCESSORTIME,
				
				PROCESSOR_PROCESSORTIME = 10

			};
		private:
			typedef std::set < PDHCounter > setCounter;
		public:
			PDH();
			virtual ~PDH();

		public:
			PDHCounter addCounter( int countType , char *processName = "_Total" );
			PDHCounter addCounter( const char *counterName );

			double getPerformance( PDHCounter counter );
		private:
			char *getCountTypeToString( int countType, char *processName = "_Total" );
			void clear();

			char m_counterName[ MAX_COUNTER_NAME ];
			HQUERY m_query;
			setCounter m_pdhCounterList;

			utillib::util::Synchronized::LockObject m_sectionPDHCounterList;

		};
	}
}

#endif